window.addEventListener("load", function () {
    // 失焦事件
    $("#userName input").addEventListener("blur", function () {
        // 表单验证
        const result = /^[a-zA-Z0-9]{6,20}$/;
        if (!result.test($("#userName input").value)) {
            $("#userName span").style.left = "410px"
        } else {
            $("#userName input").style.borderColor = "green"
        }
    })
    $("#tel input").addEventListener("blur", function () {
        // 表单验证
        const result = /^[0-9]{11}$/;
        if (!result.test($("#tel input").value)) {
            $("#tel span").style.left = "410px"
        } else {
            $("#tel input").style.borderColor = "green"
        }
    })
    $(".check input").addEventListener("blur", function () {
        // 表单验证
        const result = /^[a-zA-Z0-9]{6}$/;
        if (!result.test($(".check input").value)) {
            $(".check span").style.left = "410px"
        } else {
            $(".check input").style.borderColor = "green"
        }
    })
    $("#passWord input").addEventListener("blur", function () {
        // 表单验证
        const result = /^[a-zA-Z0-9]{6,20}$/;
        if (!result.test($("#passWord input").value)) {
            $("#passWord span").style.left = "410px"
        } else {
            $("#passWord input").style.borderColor = "green"
        }
    })
    // 未勾选协议,禁用注册按钮
    $("#register").addEventListener("click", function () {
        $(".deal p").style.color = "#666"
        $(".deal p span").style.color = "#00bdff"
        $("#register").style.backgroundColor = "#e0e0e0"
        if (!$(".deal input").checked) {
            // 未勾选协议时,协议文字变红,
            console.log(!$(".deal input").checked);
            // 禁用按钮
            $("#register").style.disabled = true

            console.log($("#register").style.disabled);
            $(".deal p").style.color = "red"
            $(".deal p span").style.color = "red"
        } else {
            console.log($("#register").style.disabled);
            $("#register").style.backgroundColor = "#00bdff"
        }
    })
})